$(function(){
	pageInit();
})

function pageInit() {
	//右上角登录信息
	$.ajax({
		url: "../customer/isLogin.action",
		type: "post",
		success: function(data) {
			if (data.success == "true") {
				var customerInfoHtml = '<li class="topbar-devider"></li>' 
					+	'<li><span style="color: #7c8082;font-size: 11px;text-transform: uppercase;">欢迎您，'+data.customerName+'</span></li>'
					+	'<li class="topbar-devider"></li>'   
					+	'<li><a href="javascript:logout()">退出</a></li>'  ;
				$("#customerInfo").html(customerInfoHtml);
			}
		},
		error: function() {
			toastr.error("获取登录信息发生错误，请联系管理员");
		}
	});
}

function logout() {
	$.ajax({
		url: "../customer/logout.action",
		type: "post",
		success: function(data) {
			if (data.success == "true") {
				window.location.href="../index.jsp";
			}else {
				toastr.error("后台处理发生错误，请稍后尝试")
			}
		},
		error: function() {
			toastr.error("提交请求发生错误，请稍后尝试");
		}
	});
}
